1. Field of the Invention
The field of the invention is data processing, or, more specifically, methods, systems, and products for single port initial context access to an Enterprise Java Bean (‘EJB’). ‘Java’ and ‘EJB’ are registered trademarks of Sun Microsystems, Inc.
2. Description of Related Art
Enterprise JavaBeans is a Java API developed by Sun Microsystems that defines a component architecture for multi-tier client/server systems. Enterprise JavaBeans define an architecture for the development and deployment of transactional, distributed object applications-based, server-side software components. These server-side components, called enterprise beans, are distributed objects that are hosted in Enterprise JavaBean containers and provide remote services for clients distributed throughout a network. These server-side components are sometimes known as ‘Enterprise JavaBeans,’ ‘EJB components,’ ‘enterprise beans,’ ‘beans,’ and sometimes by other terms as well. In this specification, however, the server side component is generally referred to as an ‘EJB.’
EJBs are software components that run in a special environment called an EJB container. The container hosts and manages an EJB in the same manner that the Java Web Server hosts a servlet or an HTML browser hosts a Java applet. An EJB functions only in an EJB container. If an enterprise bean needs to access a JDBC connection or another enterprise bean, it does so through the container; if an enterprise bean needs to access the identity of its caller, obtain a reference to itself, or access properties it does so through the container. The enterprise bean interacts with its container through one of three mechanisms: callback methods, the EJBContext interface, or the Java Naming and Directory Interface (JNDI).
A client program contacts an EJB server and requests that the server create an EJB to do data processing on behalf of the client. The server responds by creating the server-side object (the EJB component instance that is referred to generally in this specification as an ‘EJB’). The server also returns a proxy object (the EJB object, an object that implements the EJB remote interface, an object referred to generally in this specification as a ‘remote object’) whose interface is the same as the EJB's and whose implementation performs remote method invocations in the EJB on behalf of the client. The client then uses the remote object as if it were a local object, never knowing or caring that a server-side EJB is actually doing all the work.
How does a client program create objects on a server? Each EJB class has what is called a home interface, which defines the methods for creating EJB instances on the server. An EJB home interface extends the interface javax.ejb.EJBHome, which defines base-level functionality for a home interface. All methods in this interface are required to be remotely executable according to Java RMI (Remote Method Invocation). The EJB home interface also defines one or more factory methods named ‘create( ).’ The return value of these factory methods is the remote interface (that is, a remote object) for the EJB.
When a client wants to create a server-side bean, an EJB, the client uses the Java Naming and Directory Interface (JNDI) to locate the home interface for the class of bean it wants. The JNDI is a standard extension to the Java core that provides a global service to any Java environment, allowing Java programs to locate and use resources by name, to find out information about those resources, and to traverse structures of resources. A client accesses JNDI services through a method name ‘lookup( )’ in an instance of JNDI's InitialContext class. This initial context lookup returns an instance of a home interface for an EJB. In this specification, such an instance of a home interface is referred to as a ‘home object.’
Once the client has the home interface for the EJB class it wants to create, it calls one of the factory methods, that is, a create( ) method, on the home interface to create a server-side object. The client-side home interface object does a remote method call to the EJB container on the server, which then creates the EJB component, that is, the EJB itself, and returns an EJB remote object to the client. The client may then call the remote object's methods, which are forwarded to the container and then to the EJB.
Not all clients use the same version or the same instance of an EJB. Clients in fact need access to many versions and instances of an EJB. A particular instantiation of an InitialContext object by a client, however, typically requires that the client ‘know’ the location where the EJB is to be instantiated. That is, the client must be configured with the node and port of the desired instance of the EJB. In large environments, an EJB may be available at multiple locations for instantiation in many revisions or versions. In a dynamic environment, where revisions come and go rapidly, node and port assignments for server-side EJB locations frequently change, but it is the client in its InitialContexts and in their providerURL settings where the changes must be configured or installed. Such client-side reconfiguration to keep up with EJB revisions and location changes is burdensome.